package com.example.datasourcedemo.service.impl;

import com.example.datasourcedemo.aspectj.lang.annotation.DataSource;
import com.example.datasourcedemo.aspectj.lang.enums.DataSourceType;
import com.example.datasourcedemo.mapper.StudentMapper;
import com.example.datasourcedemo.service.StudentService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Map<String, Object>> getStudent() {
        PageHelper.startPage(1, 20);
        return studentMapper.getStudent();
    }

    @Override
    @DataSource(value = DataSourceType.MYSQL)
    public Map<String, Object> getStudentFromOracle() {
        return studentMapper.getStudentFromOracle();
    }
}
